package situ.com.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * Created by Gao on 2020/11/21.
 */
public class BindService extends Service{
    // logt
    private static final String TAG = "BindService";

    @Override
    public void onCreate() {
        super.onCreate();
        // logd  logm
        Log.d(TAG, "onCreate() called with: " + "");
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind() called with: " + "intent = [" + intent + "]");
        return new MyBinder();
    }

    // 在Service里面要完成播放音乐功能
    // 这里面提供的功能就是给Acitvity调用的
    class MyBinder extends Binder{
        public void play() {
            Log.d(TAG, "play() called with: " + "");
        }

        public void stop() {
            Log.d(TAG, "stop() called with: " + "");
        }
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.d(TAG, "onUnbind() called with: " + "intent = [" + intent + "]");
        return super.onUnbind(intent);
    }



    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy() called with: " + "");
    }
}
